package com.webshooter.encoder;

import com.webshooter.math.Vector;
import com.webshooter.entity.Entity;
import javax.json.Json;
import javax.json.JsonBuilderFactory;
import javax.json.JsonObjectBuilder;

public class ShootEffect implements Event {

    public String name;
    public Entity entity;
    public Vector start;
    public Vector end;
    public float angle;
    public float weaponAngleModifier;

    public ShootEffect(Entity entity, Vector end) {
        this.entity = entity;
        this.end = end;
    }

    @Override
    public JsonObjectBuilder toJson() {
        JsonBuilderFactory factory = Json.createBuilderFactory(null);
        JsonObjectBuilder builder = factory.createObjectBuilder()
                .add("type", "SHOOT_EFFECT")
                .add("startx", start.x)
                .add("starty", start.y)
                .add("endx", end.x)
                .add("endy", end.y)
                .add("angle", angle)
                .add("name", name)
                .add("weaponAngleModifier", weaponAngleModifier);
        return builder;
    }
}
